Ext.define('DCApp.view.article.Detail', {
extend: 'DCApp.view.Detail',
alias: 'widget.Articledetail',
requires: [
           'DCApp.model.Tag',
           'Ext.form.Panel',
           'Ext.form.field.Text',
           'Ext.form.field.TextArea',
           'Ext.layout.container.VBox',
           'Ext.layout.container.Anchor',
           'Ext.form.field.ComboBox',
           'Ext.form.field.Date',
           'Ext.form.CheckboxGroup'
       ],

bind: {
title: '用户 - 【{theObj.id}】'
},

componentCls: 'article-detail',
bodyPadding: 0,

controller: 'Articledetail',
tbar: ['->',{
    text: '预览',
    handler: 'onPreview'
},{
    text: '上一条',
    handler: 'onPrev',
    bind: {
        hidden: '{!showprev}'
    }
},{
    text: '下一条',
    handler: 'onNext',
    bind: {
        hidden: '{!shownext}'
    }
},{
    text: '保存',
    handler: 'onSaveClick',
    bind: {
        hidden: '{!showsave}'
    }
},{
    text: '返回',
    handler: 'onBackClick',
    bind: {
        hidden: '{!showreturn}'
    }
}],


items: [{

title: 'Panel 0',
//flex: 2,
frame: false,
xtype: 'container',
//layout: 'anchor',
style: {overflow: 'auto'},

items: [
{
title : '详情',
margin : '0 0 10 0',
cls : 'nav_pos',
reference : 'form',
bodyPadding : 10,
fieldDefaults : {
labelAlign : 'right',
labelWidth : 100,
padding : 3
},
defaults : {
anchor : '100%'
},
xtype: 'form',
items: [

{
	xtype: 'container',
	layout: 'hbox',
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	fieldLabel: '题名',
	bind: '{theObj.title}'
	},{
		//flex: 1,
		fieldLabel: '短题名',
		bind: '{theObj.stitle}'
	}]
},
{
	xtype: 'container',
	layout: 'hbox',
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	xtype: 'tags',
	fieldLabel: '标签',
	bind: '{theObj.tag}',
    anyMatch:true,
    allowBlank: false,
    createNewOnEnter: true,
    store: DCApp.Cfg.getListStore('DCApp.model.Tag','net.bat.entity.Tag','name'),
	listConfig: {
        getInnerTpl: function() {
            return '<div>{name}</div>';
        }
    },
    displayField: 'name',
    valueField: 'name'
	},{
		//flex: 1,
		fieldLabel: '链接到',
		bind: '{theObj.href}'
	}]
},
{
	xtype: 'container',
	layout: 'hbox',
	defaultType: 'textfield',
	items:[{
	//flex: 1,
    xtype: 'combotree',
    fieldLabel: '发布到',
    bind: '{theObj.postto}',
    id : 'name',  
    name : 'name',  
    hiddenName : 'hiddenName',  
    emptyText :'请选择',
    storeUrl : '/static/json/sec.json',
    cascade : 'child',//级联方式:1.child子级联;2.parent,父级联,3,both全部级联  
    rootId : '1',  
    rootText : 'DRP',  
    treeNodeParameter : '',
    publishes: ['value']
		
	},	{
		//flex: 1,
		fieldLabel: '状态',
		bind: '{theObj.status}',
		xtype: 'combobox',
		store:{
			data : [[0, '预览'],
			        [1, '发布'],
			        [2, '置顶']],
			id : 0,
			fields : ['value', 'text']
		},
		valueField : 'value',
		displayField : 'text'
	}]
},
{
	xtype: 'container',
	layout: 'hbox',
	defaultType: 'textfield',
	items:[
	{

    	xtype: 'htmleditor',
    	bind: {
            value: '{theObj.content}'
        },
    	fieldLabel: '内容'
	}]
},
	{
    xtype: 'fieldset',
    title: '更多信息',
    collapsible: true,
    collapsed:true,
    defaults: {
    labelWidth: 89,
    anchor: '100%',
    layout: {
          type: 'hbox',
          defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
         }
   }, items:[
	{
		xtype: 'container',
		layout: 'hbox',
		defaultType: 'textfield',
		items:[
		{
		//flex: 1,
		fieldLabel: '操作人id',
		bind: '{theObj.uid}'
		},	{
		//flex: 1,
		fieldLabel: '父文章id',
		bind: '{theObj.pid}'
		}]
	},
	{
		xtype: 'container',
		layout: 'hbox',
		defaultType: 'textfield',
		items:[{
		//flex: 1,
		fieldLabel: '作者',
		bind: '{theObj.author}'
		},{
			//flex: 1,
			fieldLabel: '分类',
			bind: '{theObj.stype}'
		}]
	}
      
   ]
 },

{
    title: '附件列表',
    cls:'nav_pos',
    layout:'fit',
    items:[{
    	bind:'{theObj.attaches}',
    	xtype:'attachpanel'
    }]                    
}
]}]
 }]

,initComponent: function() {   
     this.callParent(arguments);
     var fld1 = this.down('combobox[fieldLabel="状态"]')
     var role = DCApp.Cfg.usrInfo.get('roles');
     if(role =='admin' || role =='admin_xh'){
    	 fld1.setReadOnly(false);
     }else{
    	 fld1.setReadOnly(true);
     }
 }

});
